package main

import "fmt"

type Stat struct {
	IsWork   bool
	IsRest   bool
	IsLate   bool
	IsEarly  bool
	IsAbsent bool
}

// 职责系列对象

type Status interface {
	Handle(status *Stat) string
}

type Work struct{}

func (w *Work) Handle(status *Stat) string {
	if status.IsWork {
		return "工作"
	}
	return ""
}

type Rest struct{}

func (r *Rest) Handle(status *Stat) string {
	if status.IsRest {
		return "休息"
	}
	return ""
}

type Late struct{}

func (l *Late) Handle(status *Stat) string {
	if status.IsLate {
		return "迟到"
	}
	return ""
}

type Early struct{}

func (e *Early) Handle(status *Stat) string {
	if status.IsLate {
		return "早退"
	}
	return ""
}

type Absent struct{}

func (a *Absent) Handle(status *Stat) string {
	if status.IsLate {
		return "旷工"
	}
	return ""
}

type StatusHandler struct {
	Status Status
	h      []Status
}

func NewBaseStatus(h []Status) Status {
	return &StatusHandler{h: h}
}

func (sh *StatusHandler) Handle(status *Stat) string {
	//return sh.Status.Handle(status)
	for _, r := range sh.h {
		fmt.Println(r.Handle(status))
	}
	return "StatusHandler"
}

func main() {
	//work := &StatusHandler{Status: new(Work)}
	//rest := &StatusHandler{Status: work}

	base := NewBaseStatus([]Status{
		new(Work),
		new(Rest),
		new(Late),
		new(Early),
		new(Absent),
	})

	base.Handle(&Stat{
		IsWork:   false,
		IsRest:   true,
		IsLate:   false,
		IsEarly:  true,
		IsAbsent: false,
	})
}
